<?php

class Teacher_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	defined('BASE_URL')	|| define('BASE_URL', Zend_Controller_Front::getInstance()->getBaseUrl());
    }

    public function indexAction()
    {
    	//Application_Form_FrmMessage::redirector('/userWu/user-type/index');
	}
	public  function profileAction(){
	}
	public function addAction(){
		$forms = new Teacher_Form_FrmTeacher();
		$frm = $forms->formteacher();
		Application_Model_Decorator::removeAllDecorator($frm);
		$this->view->frmteacher = $frm;
		if($this->getRequest()->isPost()){
			$db = new teacher_Model_DbTable_DbTeacher();
			$data = $this->getRequest()->getPost();
			if($data['save_colse']=='save_colse'){
				$addteacher = $db->insertTeacher($data);
				print_r($data);exit();
			}
		}
	}
	public  function addTeacherAction(){
		// Show Form Teacher ///////
		$forms = new Teacher_Form_FrmTeacher();
		$frm = $forms->formteacher();
		Application_Model_Decorator::removeAllDecorator($frm);
		$this->view->frmteacher = $frm;
		///////////////////////////////////Select Db of Subject//////////
		$subject= new Application_Model_GlobalClass();
		$subjects = $subject->getSubjectOption();
		$this->view->subjects = $subjects;
		////////// Select Db of Skill//////////
		$skill = $subject->getSkillOption();
		//print_r($skills);exit();
		$this->view->skills = $skill;
		/////// Select Db Department ///////////////
		$departments = $subject->getDepartmentOption();
		$this->view->department = $departments;
		//////////Form Add Skilll///////////////
		$frmskill = $forms->addskill();
		Application_Model_Decorator::removeAllDecorator($frmskill);
		$this->view->add_frmskill = $frmskill;
		///////////////////////////////
		if($this->getRequest()->isPost()){
			//$db = new teacher_Model_DbTable_Dbteacher();
			$data = $this->getRequest()->getPost();
			if($data['save_colse']=='save_colse'){
			$db = new Teacher_Model_DbTable_DbTeacher();
			$addteacher = $db->insertTeacher($data);
			//print_r($addteacher);exit();
			}
		}
	}	
	public function getDptFilterAction(){
		if($this->getRequest()->isPost()){
			$post=$this->getRequest()->getPost();
			$dpt_id = $post["dpt_id"];	
			$sql = " SELECT	s.subject_id,s.`subject_name` FROM	tbl_subject AS s WHERE dpt_id =".$dpt_id;		
			$db = new Application_Model_DbTable_DbGlobal();
			$row=$db->getGlobalDb($sql);
			echo Zend_Json::encode($row);
			exit();
		}
	}
	/// Add avalible time
	
	public function addAvaliableAction(){
		//$this->_helper->layout()->disableLayout();
		if($this->getRequest()->isPost()){
			$_data = $this->getRequest()->getPost();
			//print_r($_data);exit();
			try{
				$db = new teacher_Model_DbTable_DbAvaliableTime();
				$sucess = $db->InsertAvaliableTime($_data);
				print_r($sucess);
				if($this->getRequest()->getPost("check_7_8_mon")){
					$insert = $db->check_7_8_mon($_data);
				}
				if($this->getRequest()->getPost("check_7_8_tur")){
					$insert = $db->check_7_8_tur($_data);
				}
				if($this->getRequest()->getPost("check_7_8_wed")){
					$insert = $db->check_7_8_wed($_data);
				}
				if($this->getRequest()->getPost("check_7_8_thu")){
					$insert = $db->check_7_8_thu($_data);
				}
				if($this->getRequest()->getPost("check_7_8_fri")){
					$insert = $db->check_7_8_fri($_data);
				}
				if($this->getRequest()->getPost("check_7_8_sat")){
					$insert = $db->check_7_8_sat($_data);
				}
				if($this->getRequest()->getPost("check_7_8_sun")){
					$insert = $db->check_7_8_sun($_data);
				}
				///
				if($this->getRequest()->getPost("check_8_10_mon")){
					$insert = $db->check_8_10_mon($_data);
				}
				if($this->getRequest()->getPost("check_8_10_tur")){
					$insert = $db->check_8_10_tur($_data);
				}
				if($this->getRequest()->getPost("check_8_10_wed")){
					$insert = $db->check_8_10_wed($_data);
				}
				if($this->getRequest()->getPost("check_8_10_thu")){
					$insert = $db->check_8_10_thu($_data);
				}
				if($this->getRequest()->getPost("check_8_10_fri")){
					$insert = $db->check_8_10_fri($_data);
				}
				if($this->getRequest()->getPost("check_8_10_sat")){
					$insert = $db->check_8_10_sat($_data);
				}
				if($this->getRequest()->getPost("check_8_10_sun")){
					$insert = $db->check_8_10_sun($_data);
				}
				////
				if($this->getRequest()->getPost("check_10_12_mon")){
					$insert = $db->check_10_12_mon($_data);
				}
				if($this->getRequest()->getPost("check_10_12_tur")){
					$insert = $db->check_10_12_tur($_data);
				}
				if($this->getRequest()->getPost("check_10_12_wed")){
					$insert = $db->check_10_12_wed($_data);
				}
				if($this->getRequest()->getPost("check_10_12_thu")){
					$insert = $db->check_10_12_thu($_data);
				}
				if($this->getRequest()->getPost("check_10_12_fri")){
					$insert = $db->check_10_12_fri($_data);
				}
				if($this->getRequest()->getPost("check_10_12_sat")){
					$insert = $db->check_10_12_sat($_data);
				}
				if($this->getRequest()->getPost("check_10_12_sun")){
					$insert = $db->check_10_12_sun($_data);
				}
				//////
				if($this->getRequest()->getPost("check_1_2_mon")){
					$insert = $db->check_1_2_mon($_data);
				}
				if($this->getRequest()->getPost("check_1_2_tur")){
					$insert = $db->check_1_2_tur($_data);
				}
				if($this->getRequest()->getPost("check_1_2_wed")){
					$insert = $db->check_1_2_wed($_data);
				}
				if($this->getRequest()->getPost("check_1_2_thu")){
					$insert = $db->check_1_2_thu($_data);
				}
				if($this->getRequest()->getPost("check_1_2_fri")){
					$insert = $db->check_1_2_fri($_data);
				}
				if($this->getRequest()->getPost("check_1_2_sat")){
					$insert = $db->check_1_2_sat($_data);
				}
				if($this->getRequest()->getPost("check_1_2_sun")){
					$insert = $db->check_1_2_sun($_data);
				}
				/////
				if($this->getRequest()->getPost("check_2_4_mon")){
					$insert = $db->check_2_4_mon($_data);
				}
				if($this->getRequest()->getPost("check_2_4_tur")){
					$insert = $db->check_2_4_tur($_data);
				}
				if($this->getRequest()->getPost("check_2_4_wed")){
					$insert = $db->check_2_4_wed($_data);
				}
				if($this->getRequest()->getPost("check_2_4_thu")){
					$insert = $db->check_2_4_thu($_data);
				}
				if($this->getRequest()->getPost("check_2_4_fri")){
					$insert = $db->check_2_4_fri($_data);
				}
				if($this->getRequest()->getPost("check_2_4_sat")){
					$insert = $db->check_2_4_sat($_data);
				}
				if($this->getRequest()->getPost("check_2_4_sun")){
					$insert = $db->check_2_4_sun($_data);
				}
				//////
				if($this->getRequest()->getPost("check_4_5_mon")){
					$insert = $db->check_4_5_mon($_data);
				}
				if($this->getRequest()->getPost("check_4_5_tur")){
					$insert = $db->check_4_5_tur($_data);
				}
				if($this->getRequest()->getPost("check_4_5_wed")){
					$insert = $db->check_4_5_wed($_data);
				}
				if($this->getRequest()->getPost("check_4_5_thu")){
					$insert = $db->check_4_5_thu($_data);
				}
				if($this->getRequest()->getPost("check_4_5_fri")){
					$insert = $db->check_4_5_fri($_data);
				}
				if($this->getRequest()->getPost("check_4_5_sat")){
					$insert = $db->check_4_5_sat($_data);
				}
				if($this->getRequest()->getPost("check_4_5_sun")){
					$insert = $db->check_4_5_sun($_data);
				}
				/////
				if($this->getRequest()->getPost("check_5_7_mon")){
					$insert = $db->check_5_7_mon($_data);
				}
				if($this->getRequest()->getPost("check_5_7_tur")){
					$insert = $db->check_5_7_tur($_data);
				}
				if($this->getRequest()->getPost("check_5_7_wed")){
					$insert = $db->check_5_7_wed($_data);
				}
				if($this->getRequest()->getPost("check_5_7_thu")){
					$insert = $db->check_5_7_thu($_data);
				}
				if($this->getRequest()->getPost("check_5_7_fri")){
					$insert = $db->check_5_7_fri($_data);
				}
				if($this->getRequest()->getPost("check_5_7_sat")){
					$insert = $db->check_5_7_sat($_data);
				}
				if($this->getRequest()->getPost("check_5_7_sun")){
					$insert = $db->check_5_7_sun($_data);
				}
				/////
				if($this->getRequest()->getPost("check_7_8_1_mon")){
					$insert = $db->check_7_8_1_mon($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_tur")){
					$insert = $db->check_7_8_1_tur($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_wed")){
					$insert = $db->check_7_8_1_wed($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_thu")){
					$insert = $db->check_7_8_1_thu($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_fri")){
					$insert = $db->check_7_8_1_fri($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_sat")){
					$insert = $db->check_7_8_1_sat($_data);
				}
				if($this->getRequest()->getPost("check_7_8_1_sun")){
					$insert = $db->check_7_8_1_sun($_data);
				}
			}catch (Exception $e){
				echo $e->getMessage();
			}
		}
		$frm = new Teacher_Form_FrmAvaliableTime();
		$form = $frm->addAvaliabletime();
		$this->view->frmavaliable = $form;
	}
	public function editTimeAction(){
		$id = $this->getRequest()->getParam("id");
		$db = new  teacher_Model_DbTable_DbAvaliableTime();
		$row = $db->getAvailableTimeByID($id);
		//print_r($row);exit();
		if($this->getRequest()->isPost()){
			$data = $this->getRequest()->getPost();
			$data["id"]= $id;
			$row = $db->UpdateAvaliableTime($data);
	
			////
			if($this->getRequest()->getPost("check_7_8_mon")){
				$insert = $db->update_check_7_8_mon($data);
			}
			if($this->getRequest()->getPost("check_7_8_tur")){
				$insert = $db->update_check_7_8_tur($data);
			}
			if($this->getRequest()->getPost("check_7_8_wed")){
				$insert = $db->update_check_7_8_wed($data);
			}
			if($this->getRequest()->getPost("check_7_8_thu")){
				$insert = $db->update_check_7_8_thu($data);
			}
			if($this->getRequest()->getPost("check_7_8_fri")){
				$insert = $db->update_check_7_8_fri($data);
			}
			if($this->getRequest()->getPost("check_7_8_sat")){
				$insert = $db->update_check_7_8_sat($data);
			}
			if($this->getRequest()->getPost("check_7_8_sun")){
				$insert = $db->update_check_7_8_sun($data);
			}
			///
			if($this->getRequest()->getPost("check_8_10_mon")){
				$insert = $db->update_check_8_10_mon($data);
			}
			if($this->getRequest()->getPost("check_8_10_tur")){
				$insert = $db->update_check_8_10_tur($data);
			}
			if($this->getRequest()->getPost("check_8_10_wed")){
				$insert = $db->update_check_8_10_wed($data);
			}
			if($this->getRequest()->getPost("check_8_10_thu")){
				$insert = $db->update_check_8_10_thu($data);
			}
			if($this->getRequest()->getPost("check_8_10_fri")){
				$insert = $db->update_check_8_10_fri($data);
			}
			if($this->getRequest()->getPost("check_8_10_sat")){
				$insert = $db->update_check_8_10_sat($data);
			}
			if($this->getRequest()->getPost("check_8_10_sun")){
				$insert = $db->update_check_8_10_sun($data);
			}
			////
			if($this->getRequest()->getPost("check_10_12_mon")){
				$insert = $db->update_check_10_12_mon($data);
			}
			if($this->getRequest()->getPost("check_10_12_tur")){
				$insert = $db->update_check_10_12_tur($data);
			}
			if($this->getRequest()->getPost("check_10_12_wed")){
				$insert = $db->update_check_10_12_wed($data);
			}
			if($this->getRequest()->getPost("check_10_12_thu")){
				$insert = $db->update_check_10_12_thu($data);
			}
			if($this->getRequest()->getPost("check_10_12_fri")){
				$insert = $db->update_check_10_12_fri($data);
			}
			if($this->getRequest()->getPost("check_10_12_sat")){
				$insert = $db->update_check_10_12_sat($data);
			}
			if($this->getRequest()->getPost("check_10_12_sun")){
				$insert = $db->update_check_10_12_sun($data);
			}
			//////
			if($this->getRequest()->getPost("check_1_2_mon")){
				$insert = $db->update_check_1_2_mon($data);
			}
			if($this->getRequest()->getPost("check_1_2_tur")){
				$insert = $db->update_check_1_2_tur($data);
			}
			if($this->getRequest()->getPost("check_1_2_wed")){
				$insert = $db->update_check_1_2_wed($data);
			}
			if($this->getRequest()->getPost("check_1_2_thu")){
				$insert  = $db->update_check_1_2_thu($data);
			}
			if($this->getRequest()->getPost("check_1_2_fri")){
				$insert = $db->update_check_1_2_fri($data);
			}
			if($this->getRequest()->getPost("check_1_2_sat")){
				$insert = $db->update_check_1_2_sat($data);
			}
			if($this->getRequest()->getPost("check_1_2_sun")){
				$insert = $db->update_check_1_2_sun($data);
			}
			/////
			if($this->getRequest()->getPost("check_2_4_mon")){
				$insert = $db->update_check_2_4_mon($data);
			}
			if($this->getRequest()->getPost("check_2_4_tur")){
				$insert = $db->update_check_2_4_tur($data);
			}
			if($this->getRequest()->getPost("check_2_4_wed")){
				$insert = $db->update_check_2_4_wed($data);
			}
			if($this->getRequest()->getPost("check_2_4_thu")){
				$insert = $db->update_check_2_4_thu($data);
			}
			if($this->getRequest()->getPost("check_2_4_fri")){
				$insert = $db->update_check_2_4_fri($data);
			}
			if($this->getRequest()->getPost("check_2_4_sat")){
				$insert = $db->update_check_2_4_sat($data);
			}
			if($this->getRequest()->getPost("check_2_4_sun")){
				$insert = $db->update_check_2_4_sun($data);
			}
			//////
			if($this->getRequest()->getPost("check_4_5_mon")){
				$insert = $db->update_check_4_5_mon($data);
			}
			if($this->getRequest()->getPost("check_4_5_tur")){
				$insert = $db->update_check_4_5_tur($data);
			}
			if($this->getRequest()->getPost("check_4_5_wed")){
				$insert = $db->update_check_4_5_wed($data);
			}
			if($this->getRequest()->getPost("check_4_5_thu")){
				$insert = $db->update_check_4_5_thu($data);
			}
			if($this->getRequest()->getPost("check_4_5_fri")){
				$insert = $db->update_check_4_5_fri($data);
			}
			if($this->getRequest()->getPost("check_4_5_sat")){
				$insert = $db->update_check_4_5_sat($data);
			}
			if($this->getRequest()->getPost("check_4_5_sun")){
				$insert = $db->update_check_4_5_sun($data);
			}
			/////
			if($this->getRequest()->getPost("check_5_7_mon")){
				$insert = $db->update_check_5_7_mon($data);
			}
			if($this->getRequest()->getPost("check_5_7_tur")){
				$insert = $db->update_check_5_7_tur($data);
			}
			if($this->getRequest()->getPost("check_5_7_wed")){
				$insert = $db->update_check_5_7_wed($data);
			}
			if($this->getRequest()->getPost("check_5_7_thu")){
				$insert = $db->update_check_5_7_thu($data);
			}
			if($this->getRequest()->getPost("check_5_7_fri")){
				$insert = $db->update_check_5_7_fri($data);
			}
			if($this->getRequest()->getPost("check_5_7_sat")){
				$insert = $db->update_check_5_7_sat($data);
			}
			if($this->getRequest()->getPost("check_5_7_sun")){
				$insert = $db->update_check_5_7_sun($data);
			}
			/////
			if($this->getRequest()->getPost("check_7_8_1_mon")){
				$insert = $db->update_check_7_8_1_mon($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_tur")){
				$insert = $db->update_check_7_8_1_tur($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_wed")){
				$insert = $db->update_check_7_8_1_wed($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_thu")){
				$insert = $db->update_check_7_8_1_thu($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_fri")){
				$insert = $db->update_check_7_8_1_fri($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_sat")){
				$insert = $db->update_check_7_8_1_sat($data);
			}
			if($this->getRequest()->getPost("check_7_8_1_sun")){
				$insert = $db->update_check_7_8_1_sun($data);
			}
			$this->_redirect("/teacher/index/");
		}
		$frm = new teacher_Form_FrmAvaliableTime();
		$form = $frm->addAvaliabletime($row);
		$this->view->frmavaliable = $form;
	}
    
}

